
<h3>&nbsp;&nbsp;&nbsp;&nbsp;Trabajo &Colon; <?php echo $this->name_job ?> &Colon;</h3>
<p>&nbsp;&nbsp;&nbsp;&nbsp;<b>Comentario</b>  &Colon; <?php echo $this->jobActivity->message ?> &Colon; </p>
<?php
$types = array('CAMBIO_BRIEF' => 'Cambio Brief', 
               'SUMAR_INFORMACION' => 'Sumar Información', 
               'CAMBIO_TIMMING' => 'Cambio Timming', 
               'INCOMPLETO_BRIEF' => 'Incompleto segun brief', 
               'FALLAS_ORTOGRAFICAS' => 'Fallas Ortográficas', 
               'NO_LE_GUSTO' => 'No le Gusto');
$chk = '';
?>
<div class="module_content">
    <form id="custom-orden-classified" method="POST" action="<?php echo $this->url(array('module' => 'orden', 'controller' => 'orden', 'action' => 'save-observation')) ?>">

        <input type="hidden" name="id_orden_job_activiy" id="id_orden_job_activiy" value="<?php echo $this->jobActivity->id ?>" />
        <input type="hidden" name="id_job" id="id_job" value="<?php echo $this->jobActivity->id_job ?>" />
        <input type="hidden" name="id_orden" id="id_orden" value="<?php echo $this->jobActivity->id_orden ?>" />
        <?php 
        $checkedClient='';
        $checkedAthos='';
        $checkedRaza='';
        $checkedVelcro='';
        if($this->observation!=null){
            if($this->observation[0]['responsibility_client'] != 0){
                $checkedClient = 'checked="checked"';
            }
            if($this->observation[0]['responsibility_athos'] != 0){
                $checkedAthos = 'checked="checked"';
            }
            if($this->observation[0]['responsibility_raza'] != 0){
                $checkedRaza = 'checked="checked"';
            }
            if($this->observation[0]['responsibility_velcro'] != 0){
                $checkedVelcro = 'checked="checked"';
            }
        }
        
        ?>
        <div>
            <table>
                <tr>
                    <td>Responsabilidad:</td>
                    <td><input type="checkbox" class="checkbox" name="checkClient" id="checkClient" value="<?php echo $this->client->id_client; ?>" <?php echo $checkedClient; ?>/><?php echo $this->client->name; ?>
                    </td>
                    <td><input type="checkbox" class="checkbox" name="checkResponsabilidadAthos" id="checkAthos" value="37" <?php echo $checkedAthos; ?>/>Athos</td>
                    <td><input type="checkbox" class="checkbox" name="checkResponsabilidadRaza" id="checkRaza" value="41" <?php echo $checkedRaza; ?>/>Raza</td>
                    <td><input type="checkbox" class="checkbox" name="checkResponsabilidadVelcro" id="checkVelcro" value="40" <?php echo $checkedVelcro; ?>/>Velcro</td>
                </tr>
            </table>
        </div>

        <?php if ($this->observation != null) { ?>
            <p class="peditorden">
                <?php foreach ($types as $key => $val) : ?>
                    <?php
                    foreach ($this->observation as $obs) {
                        if ($key == $obs->type) {
                            $chk = 'checked="checked" ';
                            break;
                        }
                    }
                    ?>
                    <input <?php echo $chk ?> type="checkbox" class="checkbox" name="checkObs[]" id="id_<?php echo $key ?>" value="<?php echo $key ?>"/><?php echo $val ?> <br/>
                    <?php
                    $chk = '';
                endforeach;
                ?>
            </p>
        <?php } else { ?>
            <p class="peditorden">
                <input type="checkbox" class="checkbox" name="checkObs[]" id="id_CAMBIO_BRIEF" value="CAMBIO_BRIEF" />Cambio Brief <br/>
                <input type="checkbox" class="checkbox" name="checkObs[]" id="id_SUMAR_INFORMACION" value="SUMAR_INFORMACION" />Sumar Informaci&oacute;n<br/>
                <input type="checkbox" class="checkbox" name="checkObs[]" id="id_CAMBIO_TIMMING" value="CAMBIO_TIMMING" />Cambio Timming<br/>
                <input type="checkbox" class="checkbox" name="checkObs[]" id="id_INCOMPLETO_BRIEF" value="INCOMPLETO_BRIEF" />Incompleto seg&uacute;n brief<br/>
                <input type="checkbox" class="checkbox" name="checkObs[]" id="id_FALLAS_ORTOGRAFICAS" value="FALLAS_ORTOGRAFICAS" />Fallas Ortogr&aacute;ficas<br/>
                <input type="checkbox" class="checkbox" name="checkObs[]" id="id_NO_LE_GUSTO" value="NO_LE_GUSTO" />No le gust&oacute;<br/>
            </p>   
        <?php }; ?>

        <p class="peditorden">Porque<br/>
            <textarea name="detail" id="detail" rows="5" cols="40" disabled="disabled"><?php echo $this->observation[0]['detail']; ?></textarea>
        </p>
        <input type="submit" class="finish" value="OK" />
    </form>
</div>

<script language="javascript">
    $('#custom-orden-classified').ajaxForm({
        dataType:  'json',
        beforeSend: function() {
            $('.loading').css('display', 'block');
        },
        complete: function(xhr) {
            $('.loading').css('display', 'none');
        },
        success: function(data){
           alert('Observacion guardada !')
        } 
    });
    //check other
    $('#id_NO_LE_GUSTO').change(function(){
        if ($(this).attr("checked")) {
            $('textarea#detail').removeAttr('disabled');
            $("input:checkbox[name='checkObs[]']:not('#id_NO_LE_GUSTO')").attr("checked",false);
            $("input:checkbox[name='checkObs[]']:not('#id_NO_LE_GUSTO')").attr("disabled",true);
            console.log('check')
        }else{
            $('textarea#detail').attr('disabled','disabled');
            $("input:checkbox[name='checkObs[]']:not('#id_NO_LE_GUSTO')").attr("disabled",false);
            console.log('no check')
        }
    });
   
</script>